<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<c:set var="contextPath" value="<%=request.getContextPath()%>"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
	<head>
		<title>科目列表</title>
		<style>
		</style>
		<script src="${contextPath}/static/lib/jquery-migrate-1.1.0.js"></script>
		<script src="${contextPath}/static/lib/jquery.jqprint-0.3.js"></script>
		<script type="text/javascript">
		$(function(){
			$('.showScoreBtn').click(function(){
				var scoreId = $(this).attr('scoreId');
				$.ajax({
					type: 'POST',
					url: '${contextPath}/student/showScore',
					data: {
						scoreId: scoreId
					},
					dataType: "json",
					success: function(data){
						$('#userName').text(data.userName);
						$('#subjectName').text(data.subjectName);
						$('#examTime').text(data.examTimeString);
						$('#score').text(data.score);
						$('#showScoreModal').modal('show');
					}
				});
			});//使用jqprint打印modal框内的内容
			$('#scorePrint').click(function() {
				$('#showScoreModal .modal-body').jqprint();
			});
			$('.to-test').click(function(){
				return confirm("是否确认要参加该科目考试？");
			});
		});
		</script>
	</head>

	<body>
		<div id="messageDiv">
			<c:if test="${not empty message }">
				<script type="text/javascript">
					alert("${message}");
				</script>
			</c:if>
		</div>
		
		<!--显示成绩－模态框（Modal）-->
		<div  class="modal fade"  id="showScoreModal"  tabindex="-1"  role="dialog"  aria-labelledby="showScoreModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="showScoreModalLabel">查看科目成绩</h4>
					</div>
					<div class="modal-body">
						<p><label>用户名:</label><label id="userName">andy</label></p>
						<p><label>科目名:</label><label id="subjectName">English</label></p>
						<p><label>考试时间:</label><label id="examTime">2016-10-18</label></p>
						<p><label>得分:</label><label id="score">80</label></p>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button id="scorePrint" type="button" class="btn btn-primary">打印</button>
					</div>
				</div><!--/.modal-content -->
			</div><!--/.modal -->
		</div>
		
		<div class="page-content-area">
			<div class="page-header">
			</div><!-- /.page-header -->

			<div class="row">
				<div class="col-xs-12">
					<!-- PAGE CONTENT BEGINS -->
					<div class="row">
						<div class="col-xs-12">
							<table id="sample-table-1" class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
                                        <th>科目编号</th>
                                        <th>科目名</th>
                                        <th>科目描述</th>
                                        <th>科目题数</th>
                                        <th>总时长</th>
                                        <th>满分总分</th>
                                        <th>是否开启考试</th>
                                        <th>本科目得分</th>
                                        <th>是否已参考</th>
                                        <th>操作</th>
                                    </tr>
								</thead>

								<tbody>
	                            <c:forEach items="${examSubjectList }" var="sub">
	                                <tr>
                                        <td>${sub.subId }</td>
                                        <td>${sub.name }</td>
                                        <td>${sub.description }</td>
                                        <td>${sub.testCount }</td>
                                        <td>${sub.totalTime }</td>
                                        <td>${sub.totalScore }</td>
                                        <td>
                                        	<c:choose>
                                        		<c:when test="${sub.status == 0 }">
                                        			<label class="label arrowed">已关闭</label>
                                        		</c:when>
                                        		<c:otherwise>
                                        			<label class="label label-success arrowed-in arrowed-in-right">已开启</label>
                                        		</c:otherwise>
                                        	</c:choose>
                                        </td>
                                        <td>${sub.score.score }</td>
                                        <td>
	                                        <c:choose>
		                                        <c:when test="${sub.score == null }">
		                                        	<label class="label label-success arrowed-in arrowed-in-right">未参考</label>
		                                        </c:when>
		                                        <c:otherwise>
		                                        	<label class="label arrowed">已参考</label>
		                                        </c:otherwise>
	                                        </c:choose>
                                        </td>
                                        <td>
	                                        <c:choose>
		                                        <c:when test="${sub.score == null }">
			                                        <c:choose>
				                                        <c:when test="${sub.status == 0 }">
					                                        <a title="进入考试" disabled="disabled" class="btn btn-success btn-xs">
					                                        	<i class="ace-icon fa fa-pencil"></i>
					                                        </a>
				                                        </c:when>
				                                        <c:otherwise>
					                                        <a title="进  入  考  试" href="${contextPath }/student/toTest/${sub.subId }" class="btn btn-success btn-xs to-test">
					                                        	<i class="ace-icon fa fa-pencil"></i>
					                                        </a>
				                                        </c:otherwise>
			                                        </c:choose>
		                                        </c:when>
		                                        <c:when test="${empty sub.score.score && sub.score.remainingExamTime > 0}"><!--已经开始考试，中途关闭-->
			                                        <a title="进入考试" href="${contextPath }/student/toTest/${sub.subId }" class="btn btn-success btn-xs to-test">
			                                        	<i class="ace-icon fa fa-pencil"></i>
			                                        </a>
		                                        </c:when>
		                                        <c:otherwise>
			                                        <a title="查看成绩" scoreId="${sub.score.id }" class="btn btn-info btn-xs showScoreBtn">
			                                        	<i class="ace-icon fa fa-eye"></i>
			                                        </a>
		                                        </c:otherwise>
	                                        </c:choose>
                                        </td>
									</tr>
								</c:forEach>
								</tbody>
							</table>
						</div><!-- /.span -->
					</div><!-- /.row -->

					<div class="hr hr-18 dotted hr-double"></div>
				</div><!-- /.col -->
			</div><!-- /.row -->
		</div><!-- /.page-content-area -->
	</body>
</html>